<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
/**
 * 空模块，主要用于显示404页面，请不要删除
 */
class HolidayController extends HomeController{
	//没有任何方法，直接执行HomeController的_empty方法
	//请不要删除该控制器
	public function holidayGet(){
		$data = I('get.');
		 $json['success'] = true;
		if(isset($data['date_start'])){
			$date_start = $data['date_start'];
		}else{
			$json['success'] = false;
			$json['error'] = '请输入开始时间';
		}
		
		if($json['success']){
			if(isset($data['date_end'])){
				if($date['date_start'] <= $data['date_end']){
					$date_end = $data['date_end'];
				}else{
					$json['success'] = false;
					$json['error'] = '结束时间必须大于等于开始时间';
				}
			}else{
				$date_end = $date_start;
			}
		}

		if($json['success']){
			$holidayModel = D('holiday');
	        $holiday_data = $holidayModel->getHoliday();
	        foreach ($holiday_data as $key => $value) {
	        	if($this->is_in_intersection($date_start,$date_end,$value['date_start'],$value['date_end'])){
	        		$temp_data = $value;
	        		$temp_data['date_end'] = intval($value['date_end']);
	        		$temp_data['date_start'] = intval($value['date_start']);
	            	$info[] = $temp_data; 
	            }
	        }
		}

		$json['info'] = $info;

		$this->ajaxReturn($json);
	}

	
}
